package com.aboat.action;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 新增
 *
 * @author aboat
 * @email clear_windy@yeah.net
 * @create 2017-04-09 17:21
 */
public class AddMinusRegularListener implements ActionListener {
    DefaultTableModel tableModel;
    JTextField field;
    public AddMinusRegularListener(DefaultTableModel tableModel, JTextField field) {
        this.tableModel = tableModel;
        this.field = field;
    }



    @Override
    public void actionPerformed(ActionEvent e) {
        String str = field.getText();
        if(str != null) {
            str = str.replace(" ", "");
            if(str.trim().length()>0){
                str = str.trim();
                String[] tableVales = {str};
                tableModel.addRow(tableVales);
                field.setText("");
            }
        }
    }
}
